package com.zhanglu.fun.services.datacenter.user;

import java.util.List;

import com.zhanglu.fun.services.datacenter.entity.User;
import org.springframework.beans.factory.annotation.Autowired;

import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

/**
 * @author zhanglu
 * @description
 * @date 2017/6/11 18:01
 */
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public User getUserByUsernameAndPassword(String username, String password) {
        return userMapper.selectOne(new User()
                .setUsername(username)
                .setPassword(password));
    }

    public List<User> queryUsers(User user) {
        if (user.getPage() != null && user.getRows() != null) {
            PageHelper.startPage(user.getPage(), user.getRows());
        }
        return userMapper.select(user);
    }
}
